package com.lv.common.utils;

import java.io.UnsupportedEncodingException;

/**
 * 不抛出异常的URLEncoder工具类
 */

public final class URLEncoder {
    public static String encode(String originStr, String enc) {
        try {
            return java.net.URLEncoder.encode(originStr, enc);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return "";
        }
    }
    public static String encodeWithUtf8(String originStr) {
        return encode(originStr, "UTF-8");
    }
    public static String getURLDecoderString(String str) {
        String result = "";
        if (null == str) {
            return "";
        }
        try {
            result = java.net.URLDecoder.decode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }
}
